home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / kaffe-0.2 / lib / native / java.lang / java.lang.Thread.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  1.8 KB  |  99 lines

  1. /*
  2.  * java.lang.Thread.c
  3.  *
  4.  * Copyright (c) 1996 Systems Architecture Research Centre,
  5.  *           City University, London, UK.
  6.  *
  7.  * See the file "license.terms" for information on usage and redistribution
  8.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9.  *
  10.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
  11.  */
  12.  
  13. #include <native.h>
  14. #include "java.lang.Thread.h"
  15. #include "java.lang.ThreadGroup.h"
  16. #include "../../kaffe/gtypes.h"
  17. #include "../../kaffe/thread.h"
  18.  
  19. struct Hjava_lang_Thread*
  20. java_lang_Thread_currentThread()
  21. {
  22.     return ((struct Hjava_lang_Thread*)currentThread);
  23. }
  24.  
  25. /*
  26.  * Yield processor to another thread of the same priority.
  27.  */
  28. void
  29. java_lang_Thread_yield()
  30. {
  31.     yieldThread();
  32. }
  33.  
  34. /*
  35.  * Put current thread to sleep for a time.
  36.  */
  37. void
  38. java_lang_Thread_sleep(long long time)
  39. {
  40.     sleepThread(time);
  41. }
  42.  
  43. /*
  44.  * Start this thread running.
  45.  */
  46. void
  47. java_lang_Thread_start(struct Hjava_lang_Thread* this)
  48. {
  49.     startThread((thread*)this);
  50. }
  51.  
  52. /*
  53.  * Is this thread alive?
  54.  */
  55. long /* bool */
  56. java_lang_Thread_isAlive(struct Hjava_lang_Thread* this)
  57. {
  58.     return (aliveThread((thread*)this));
  59. }
  60.  
  61. /*
  62.  * Number of stack.  One for the moment.
  63.  */
  64. long
  65. java_lang_Thread_countStackFrames(struct Hjava_lang_Thread* this)
  66. {
  67.     return (framesThread((thread*)this));
  68. }
  69.  
  70. /*
  71.  * Change thread priority.
  72.  */
  73. void
  74. java_lang_Thread_setPriority0(struct Hjava_lang_Thread* this, long prio)
  75. {
  76.     setPriorityThread((thread*)this, prio);
  77. }
  78.  
  79. /*
  80.  * Stop a thread in its tracks.
  81.  */
  82. void
  83. java_lang_Thread_stop0(struct Hjava_lang_Thread* this, struct Hjava_lang_Object* obj)
  84. {
  85.     killThread((thread*)this);
  86. }
  87.  
  88. void
  89. java_lang_Thread_suspend0(struct Hjava_lang_Thread* this)
  90. {
  91.     suspendThread((thread*)this);
  92. }
  93.  
  94. void
  95. java_lang_Thread_resume0(struct Hjava_lang_Thread* this)
  96. {
  97.     resumeThread((thread*)this);
  98. }
  99.